package cn.dengta.webapp.user.dto;

import java.util.*;

import cn.dengta.common.util.Common;
import cn.dengta.webapp.base.vo.AbstractVO;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.StringUtil;

@Getter
@Setter
public class UserMenuPermissionDTO extends AbstractVO<Void> {

	/** 菜单方法key（唯一） */
	protected String routeCode;
	/** 菜单权限码 */
	protected String permissionCode;

	protected Set<String> permissionSet;
	protected Set<String> routeCodeSet;

	public Set<String> getRouteCodeSet() {
		if (routeCodeSet != null) {
			return routeCodeSet;
		}
		return routeCodeSet = StringUtil.notEmpty(routeCode) ? new HashSet<>(Common.splitAsStringList(routeCode)) : Collections.emptySet();
	}

	public UserMenuPermissionDTO init() {
		this.routeCode = "";
		this.permissionCode = "";
		return this;
	}

	public Set<String> getPermissionSet() {
		if (permissionSet != null) {
			return permissionSet;
		}
		return permissionSet = StringUtil.notEmpty(permissionCode) ? new HashSet<>(Common.splitAsStringList(permissionCode)) : Collections.emptySet();
	}

}
